package com.xdh.springcloud.consumer.helloword.controller;


import com.xdh.springcloud.consumer.helloword.service.HelloWordService;
import com.xdh.springcloud.consumer.helloword.service.PostgresqlService;
import com.xdh.springcloud.producer.helloword.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("action")
public class HelloWordController {
    @Autowired
    private HelloWordService helloWordService;

    @RequestMapping(value = "/sayHello", method = {RequestMethod.GET, RequestMethod.POST})
    public Object sayHello(String name) {
        return helloWordService.sayHello(name);
    }

    @RequestMapping(value = "/sayHello2", method = {RequestMethod.GET, RequestMethod.POST})
    public Object sayHello2(String name, int age) {
        User user = new User();
        user.setAge(age);
        user.setName(name);
        user = helloWordService.sayHello(user);
        return user;
    }

}
